package top.xiaodaiyu.shiro.auth.config;

import org.apache.shiro.cache.Cache;
import org.apache.shiro.cache.CacheException;
import org.apache.shiro.cache.CacheManager;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

/**
 * @author by  Administrator
 * 包名空间  top.xiaodaiyu.shiro.auth.config
 * 用途
 * Created by dtt on 2018/8/2
 * Email 532199946@qq.com
 **/
public class JedisCacheManager implements CacheManager {

    private static ConcurrentMap<String, Cache> caches = new ConcurrentHashMap<String, Cache>();

    @Override
    public <K, V> Cache<K, V> getCache(String s) throws CacheException {

        Cache cache = caches.get(s);
        if(cache == null){
            cache = new JedisCache();
            caches.put(s,cache);
        }
        return cache;
    }
}
